<template>
  <div class="cm-transaction-list bg-c-fff right-height mb70">
    <div class="bread rel">
      <a href="javascript:void(0);" class="font-s-16">业务管理部-交易监控订单管理</a>
    </div>
    <div class="content">
      <choose-type typename="订单状态" valuename="orderType" :itemlist="orderlist" :active="orderActive" @typechanged="onOptionChanged"></choose-type>
      <choose-type typename="交易阶段" valuename="transType" :itemlist="translist" :active="transActive" @typechanged="onOptionChanged"></choose-type>
      <choose-type typename="监控类型" valuename="typeType" :itemlist="typelist" :active="typeActive" @typechanged="onOptionChanged"></choose-type>
      <table class="auto" width="100%">
        <tr>
          <th>订单时间</th>
          <th>订单编号</th>
          <th>发起人</th>
          <th>监控类型</th>
          <th>交易阶段</th>
          <th>订单状态</th>
          <th>监控师</th>
          <th>监控员</th>
          <th>操作</th>
        </tr>
        <tr v-for="item in list">
          <td>{{item.createTime}}</td>
          <td>{{item.id}}</td>
          <td>{{item.businessName}}</td>
          <td>{{item.monitorType | monitorTypeFilter}}</td>
          <td>{{item.status | statusFilter}}</td>
          <td>{{item.stage | stageFilter}}</td>
          <td>{{item.monitorName | nameFilter}}</td>
          <td>{{item.workerName | nameFilter}}</td>
          <td>
            <button class="blue-button small-btn-css" @click="onDetailsClick(item.id,item.status)">查看详情</button>
          </td>
        </tr>
      </table>
      <div class="fix foot-box ">
        <pagination :index="pageIndex" :total="pageTotal" v-show="this.list!=0" @pagechange="onPageChange"></pagination>
      </div>
    </div>
  </div>
</template>
<script type="text/javascript ">
import Pagination from '../components/Pagination'
import ChooseType from '../components/ChooseType'
export default {
  components: {
    Pagination,
    ChooseType
  },
  data() {
    return {
      pageIndex: 1,
      pageTotal: 0,
      orderActive: '',
      orderlist: [{
        value: '',
        text: '全部'
      }, {
        value: '0',
        text: '待分配'
      }, {
        value: '1',
        text: '进行中'
      }, {
        value: '3',
        text: '已终止'
      }, {
        value: '2',
        text: '已完成'
      }],
      transActive: '',
      translist: [{
        value: '',
        text: '全部'
      }, {
        value: '2',
        text: '查看资质报告'
      }, {
        value: '3',
        text: '合同审查'
      }, {
        value: '4',
        text: '监控师绘图'
      }, {
        value: '5',
        text: '监控员交易监控'
      }],
      typeActive: '',
      typelist: [{
        value: '',
        text: '全部'
      }, {
        value: '1',
        text: '单方监控'
      }, {
        value: '2',
        text: '双方监控'
      }, {
        value: '3',
        text: '多方监控'
      }],
      list: []
    }
  },
  mounted() {
    this.onPageChange(1)
  },
  methods: {
    onOptionChanged(type, value) {
      if (type === 'orderType') {
        this.orderActive = value
      }
      if (type === 'transType') {
        this.transActive = value
      }
      if (type === 'typeType') {
        this.typeActive = value
      }
      this.getData(1)
    },
    onPageChange(n) {
      this.getData(n)
    },
    getData(n) {
      var parms = {
        status: this.transActive,
        stage: this.orderActive,
        monitorType: this.typeActive,
        page: n,
        rows: 10
      }
      this.$http.get('/transactionMonitorSer/chief/read/list', {
        params: parms
      }).then(data => {
        if (data.data.httpCode === 200) {
          this.pageIndex = n
          this.pageTotal = Math.ceil(data.data.total / 10)
          this.list = data.data.rows
          // console.log(this.list)
        } else {
          console.log(data.data.msg)
          this.$toasted.show(data.data.msg)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    onDetailsClick(id, status) {
      if (status === 2) {
        this.$router.push('/cm-transaction-aptitude?type=business&id=' + id)
      }
      if (status === 3) {
        this.$router.push('/cm-transaction-contract?type=business&id=' + id)
      }
      if (status === 4) {
        this.$router.push('/cm-transaction-drawing?type=business&id=' + id)
      }
      if (status >= 5) {
        this.$router.push('/cm-transaction-flow?type=business&id=' + id)
      }
    }
  },
  filters: {
    monitorTypeFilter(m) {
      if (m === 1) {
        return '单方监控'
      } else if (m === 2) {
        return '双方监控'
      } else if (m === 3) {
        return '多方监控'
      }
    },
    statusFilter(m) {
      if (m === 2) {
        return '查看资质报告'
      } else if (m === 3) {
        return '合同审查'
      } else if (m === 4) {
        return '监控师绘图'
      } else if (m >= 5) {
        return '监控员交易监控'
      }
    },
    stageFilter(m) {
      if (m === 0) {
        return '待分配'
      } else if (m === 1) {
        return '进行中'
      } else if (m === 2) {
        return '已完成'
      } else if (m === 3) {
        return '已终止'
      }
    },
    nameFilter(n) {
      if (!n) {
        return '--'
      } else {
        return n
      }
    }
  }
}

</script>
<style type="text/css " scoped>
.bread {
  padding-left: 20px;
  height: 50px;
  border-bottom: 1px solid #ddd;
}

.bread a {
  line-height: 50px;
}

.content {
  margin-top: 30px;
  padding: 0 30px;
}

.content table {
  margin-top: 20px;
}

.content table td button:nth-of-type(1) {
  margin-bottom: 7px;
}


.foot-box {
  padding: 35px 0px 0px 0px;
}

.pagination {
  width: auto!important;
  margin: 0 auto!important;
}

.vodal-main .con {
  padding: 4px 13px;
}

.vodal-main .con p {
  margin-bottom: 15px;
}

.vodal-main .con p span {
  width: 94px;
  display: inline-block;
}

select {
  width: 110px;
  height: 35px;
  border: 1px solid #ddd;
}

</style>
